// pages/tibaoList/tibaoList.js
var common = require("../../utils/public.js") //引入public.js脚本
var api = require("../../utils/api");
const time = require('../../utils/time.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:[],
    createtime:[]
  },
  // 跳转提报商品页
  totibao: common.throttleFunc(function (e) {
    wx.navigateTo({
      url: '/pages/tibao/tibao',
    })
  }),
  // 跳转提报商品详情
  totibaoItem: common.throttleFunc(function (e) {
    wx.navigateTo({
      url: '/pages/tibaoItem/tibaoItem?id=' + e.currentTarget.dataset.id,
    })
  }),

  onLoad: function (options) {
    
    
  },
  onShow:function(){
    let that = this 
    api.demandList({
      cityId: wx.getStorageSync("cityId"),
      createid: wx.getStorageSync("openId"),
      page: {
        startPage: false,
        current: 1,
        size: 10
      }
    }).then(res => {
      if (res.result) {
        let arr=[]
        res.object.records.forEach(function(v){
          arr.push(time.formatTimeTwo(v.createtime, 'Y/M/D h:m:s'))
        })
        that.setData({
          list: res.object.records,
          createtime:arr
        })
      }
    })
  }

})